/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jardownloader;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;

/**
 *
 * @author BB
 */
public class Checker {
    long modified;
    long checkFile(String url_str)
            throws IllegalStateException, MalformedURLException,
            ProtocolException, IOException {

        URL url = new URL(url_str.replace(" ", "%20"));

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        conn.setRequestMethod("GET");

        conn.connect();

        int responseCode = conn.getResponseCode();

        if (responseCode == HttpURLConnection.HTTP_OK) {

            InputStream is = conn.getInputStream();
            modified = conn.getLastModified();

         } else {
            throw new IllegalStateException("HTTP response: " + responseCode);
        }
        return modified;
    }
}
